#include "UdpServer.hpp"
#include "Dict.hpp"

#include <memory>

int main(int argc, char**argv)
{   
    if(argc != 2)
    {
        std::cerr <<  "Usage " << argv[0] <<" -port" << std::endl;
        exit(1);
    }
    // 获取用户输入的端口号
    uint16_t port = std::stoi(argv[1]);

    Dict dict("./dict.txt");
    // 包装一个业务函数 -- 英译汉
    func_t translate = std::bind(&Dict::translate, &dict, std::placeholders::_1);

    std::unique_ptr<UdpServer> uvsr = std::make_unique<UdpServer>(translate, port);// C++14
    uvsr->Init();
    uvsr->Start();

    return 0;
}